package com.lin.cloud.disk.controller;

import com.lin.cloud.disk.common.entity.request.AccountRequestDTO;
import com.lin.cloud.disk.common.utils.Result;
import com.lin.cloud.disk.entity.request.file.GetFileStoreDateTableRequest;
import com.lin.cloud.disk.entity.response.CountTotalSizeResponse;
import com.lin.cloud.disk.entity.response.GetFileResourceZoneResponse;
import com.lin.cloud.disk.entity.response.GetFileStoreDateTableResponse;
import com.lin.cloud.disk.manage.IDashboardManageService;
import com.lin.cloud.disk.manage.IFileManageService;
import com.lin.cloud.disk.service.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: cloud-disk
 * @description: 仪表盘控制器
 * @author: Lin
 * @create: 2021-02-15 16:21
 **/
@RestController
@RequestMapping("/api/dashboard")
@Slf4j
@Api(tags = "仪表盘控制器")
public class DashboardController {

    @Resource
    private IFileService fileService;

    @Resource
    private IFileManageService fileManageService;

    @Resource
    private IDashboardManageService dashboardManageService;

    /**
     * 统计总文件大小
     * @param request
     */
    @PostMapping(value = "/countTotalSize")
    @ApiOperation(value = "统计总文件大小")
    public Result<CountTotalSizeResponse> countTotalSize(@RequestBody @Validated AccountRequestDTO request){
        return Result.success(dashboardManageService.countTotalFileSize(request));
    }


    /**
     * 获取文件资源分片
     * @param request
     * @return
     */
    @PostMapping(value = "/getFileResourceZone")
    @ApiOperation(value = "获取文件资源分片")
    public Result<List<GetFileResourceZoneResponse>> getFileResourceZone(@RequestBody @Validated AccountRequestDTO request){
        return Result.success(fileService.getFileResourceZone(request));
    }

    /**
     * 获取文件指定存储日期报表
     * @param request
     * @return
     */
    @PostMapping(value = "/getFileStoreDateTable")
    @ApiOperation(value = "获取文件指定存储日期报表")
    public Result<List<GetFileStoreDateTableResponse>> getFileStoreDateTable(@RequestBody @Validated GetFileStoreDateTableRequest request){
        return Result.success(fileManageService.getFileStoreDateTable(request));
    }

}
